package com.itheima.condition.config;

import com.itheima.condition.condition.ClassCondition;
import com.itheima.condition.condition.MyConditionalOnClass;
import com.itheima.condition.domain.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration
public class UserConfig {

    //将User实体类放入Bean
    //1.如果没有条件，User对象放入Bean里
    //2.加入Condition条件
    //  @Conditional注解里，需要导入Condition实现类
    //  加载一个User，创建一个Condition实现类
    //3.不应该写死"redis.clients.jedis.Jedis"，在Condition注解里导入

    //@Conditional(ClassCondition.class)
    @Bean
    //@MyConditionalOnClass({"redis.clients.jedis.Jedis"})

    @ConditionalOnProperty(name = "itcast", havingValue = "itheima")
    public User user(){
        return new User();
    }
}
